/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$("#checkall").click(function(){
    if($('#checkall').is(':checked')){
        $("input[name='option']:checkbox").prop("checked", true);
    }else{
        $("input[name='option']:checkbox").prop("checked", false);
    }
});

function getcheckids(){
    var ids = [];
    $("input[name='option']:checked").each(function(){   
        ids.push($(this).data("id"));    
    });  
    var delIds=ids.join(",");   
    //console.log(delIds);
    return delIds;
}


//时间戳转日期
function timestampToTime(timestamp,status) {
    var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear();
    M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
    D = date.getDate();
    h = date.getHours();
    m = date.getMinutes();
    s = date.getSeconds();
    if (status == 1) {//自定义返回格式 2018-01-01
        return Y+'-'+M+'-'+D;
    }else{//返回格式 2018-01-01 12:12:12
        return Y+'-'+M+'-'+D+' '+h+':'+m+':'+s;
    }
    
    
    
}
function getsec(str)
{ 
   //alert(str); 
   var str1=str.substring(1,str.length)*1; 
   var str2=str.substring(0,1); 
   if (str2=="s")
   { 
        return str1*1000; 
   }
   else if (str2=="h")
   { 
       return str1*60*60*1000; 
   }
   else if (str2=="d")
   { 
       return str1*24*60*60*1000; 
   } 
} 

function setCookie(name,value,time) 
{ 
    var strsec = getsec(time); 
    var exp = new Date(); 
    exp.setTime(exp.getTime() + strsec*1); 
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();  
} 

function getCookie(name) 
{ 
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
 
        return unescape(arr[2]); 
    else 
        return null; 
} 

function delCookie(name) 
{ 
    var exp = new Date(); 
    exp.setTime(exp.getTime() - 1); 
    var cval=getCookie(name); 
    if(cval!=null) 
        document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
} 